<?
	require_once('init.php');
	require_once('dataModel.php');

	$type=$_POST["Type"];
    
    switch($type)
    {
        case "LoginInfo":   //系统登陆
    	{
			$verifycode=$_POST["varifyID"];
			
			if ($_SESSION['security_code']!=$verifycode)
			{
			  	echo "-1";  //提示验证码错误
				exit;
			}
			$userName = strval($_POST["userName"]);
			$userPwd = strval($_POST["userPWD"]);
			$pwdkey = '@#$%';
			$userPwd = md5($userPwd.$pwdkey);
			$strSQL = "select * from userInfo ";  
			$strSQL .="where userName='$userName' limit 0,1 "; //Type=1000的才是管理员

			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->query($strSQL); 
	      	$result=$db->fetch($DBR);
		    $rs_pwd=$result["userPWD"];
		    if(!empty($rs_pwd)&&$rs_pwd==$userPwd){
				$_SESSION["userName"]=$result["userName"];
				$_SESSION["UID"]=$result["id"];
				$_SESSION["userType"]=$result["type"];
				$_SESSION['flag'] = '6275ffcfb9cd8f95984b93b0a7bfcefd';
				$_SESSION["realName"]=$result["realName"];
				$_SESSION["userAddress"]=$result["userAddress"];
				$_SESSION["telCode"]=$result["telCode"];
				echo "1"; 
				exit();
		    }else{
		    	echo "2";   //用户或密码错误
				exit();	
		    }
    	}
    	
         case "registinfo":   //会员注册
    	{
			
			$userName = strval($_POST["userName"]);
			$userPwd = strval($_POST["userPWD"]);
			$email = strval($_POST["email"]);
			$pwdkey = '@#$%';
			$userPWD = md5($userPwd.$pwdkey);
			
			
			//$userName=str_replace(' or ', '',$userName); //防止有人作弊
			//$userName=str_replace(' || ', '',$userName); //防止有人作弊
			//$userPWD=str_replace(' ', '',$userPWD);      //防止有人作弊
			
			$strSQL="select count(*) AS RowNum ";  
			$strSQL .="from userInfo ";  
			$strSQL .="where userName='$userName' limit 0,1 ";

			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->query($strSQL); 
	      	$result=$db->fetch($DBR);
		    $rs_count=$result["RowNum"];
		    
		    if($rs_count>0)
		    {
				echo "2";   //用户或密码错误
				exit();		
			}
			

		    //新增用户资料
			$qry="INSERT INTO userInfo (userName,userPWD,email,loginTime,type) ";  
			$qry .= "VALUES ('$userName','$userPWD','$email',now(),0)"; 			//默认1个客服数量
			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->update($qry); 

			$strSQL="select * ";  
			$strSQL .="from userInfo ";  
			$strSQL .="where userName='$userName' limit 0,1 ";

			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->query($strSQL); 
	      	$result=$db->fetch($DBR);
			
			$_SESSION["userName"]=$result["userName"];
			$_SESSION["UID"]=$result["id"];
			$_SESSION["userType"]=$result["type"];
			$_SESSION['flag'] = '6275ffcfb9cd8f95984b93b0a7bfcefd';
			$_SESSION["realName"]=$result["realName"];
			$_SESSION["userAddress"]=$result["userAddress"];
			$_SESSION["telCode"]=$result["telCode"];
           			
			echo "1"; 
			exit();    	
    	}
    	
        case "editpassword":   //修改密码
    	{
		  	$userPWD = $_POST["userPWD"];
		  	$oldPWD = $_POST["oldPWD"];
		    $UID=$_SESSION["UID"];
		
			$strSQL="select COUNT(*) AS RowNum from userInfo where userPWD='$oldPWD' and id='$UID' limit 0,1 "; 
			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->query($strSQL); 
	      	$result=$db->fetch($DBR);
		    $rs_count=$result["RowNum"];
		    
		    if($rs_count==0)
		    {
				echo "2";   //密码错误
				exit();		
			}
			    
		    //更改密码
			$strSQL = "update userInfo set userPWD='$userPWD' where id='$UID' limit 1 ";
			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->update($strSQL); 
		
			echo "1"; 
			exit();

			break;  
    	}
    	
        case "edituserinfo":   //修改个人资料
    	{
		  	$email = $_POST["email"];
		  	$telCode = $_POST["telCode"];
		  	$qqCode = $_POST["qqCode"];
		  	$userAddress = $_POST["userAddress"];
		  	$realName = $_POST["realName"];
		    $UID=$_SESSION["UID"];
		
		    //更改资料
			$strSQL = "update userInfo set email='$email',telCode='$telCode',qqCode='$qqCode',realName='$realName',userAddress='$userAddress'where id='$UID' limit 1 ";
			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->update($strSQL); 
		
//		    echo $strSQL;
			echo "1"; 
			exit();

			break;  
    	}

        case "edituserdata":   //修改聊天室名称
    	{
		  	$roomName = $_POST["roomName"];
		    $UID=$_SESSION["UID"];
		
		    //更改资料
			$strSQL = "update roomBaseInfo set roomName='$roomName' where userID='$UID' limit 1 ";
			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->update($strSQL); 
		
//		    echo $strSQL;
			echo "1"; 
			exit();

			break;  
    	}

        case "DeleteEmp":   //删除客服人员
    	{
		  	$EID = $_POST["EID"];
		    $UID=$_SESSION["UID"];
		
		    //删除客服人员
			$strSQL = "DELETE FROM empInfo WHERE id='$EID' AND shopRoomID='$UID' limit 1 ";
			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->update($strSQL); 
		
//		    echo $strSQL;
			echo "1"; 
			exit();

			break;  
    	}

         case "AddEmpName":   //新增客服
    	{
			
			$empName = $_POST["empName"];
			$empPwd = $_POST["empPwd"];
			$imNumber = $_POST["imNumber"];
			$imType = $_POST["imType"];
			
			$empName=str_replace(' or ', '',$empName); //防止有人作弊
			$empName=str_replace(' || ', '',$empName); //防止有人作弊
			$empPwd=str_replace(' ', '',$empPwd);      //防止有人作弊
            
            
            //判断是否超出允许人数
			$strSQL="select count(*) AS RowNum ";  
			$strSQL .="from empInfo ";  
			$strSQL .="where shopRoomID='".$_SESSION["UID"]."'";

			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->query($strSQL); 
	      	$result=$db->fetch($DBR);
		    $empNum=$result["RowNum"];

			$strSQL="select effectNum ";  
			$strSQL .="from userInfo ";  
			$strSQL .="where id='".$_SESSION["UID"]."'";

			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->query($strSQL); 
	      	$result=$db->fetch($DBR);
		    $effectNum=$result["effectNum"];
		    
		    if($empNum>=$effectNum)
		    {
				echo "3";   //用户或密码错误
				exit();		
			}
			
			$strSQL="select count(*) AS RowNum ";  
			$strSQL .="from empInfo ";  
			$strSQL .="where empName='$empName' AND shopRoomID=".$_SESSION["UID"]." limit 0,1 ";

			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->query($strSQL); 
	      	$result=$db->fetch($DBR);
		    $rs_count=$result["RowNum"];
		    
		    if($rs_count>0)
		    {
				echo "2";   
				exit();		
			}
			

		    //新增客服资料
			$strSQL="INSERT INTO empInfo (shopRoomID,empName,empPwd,imNumber,imType,empType) ";  
			$strSQL .= "VALUES ('".$_SESSION["UID"]."','".$empName."','".$empPwd."','".$imNumber."',".$imType.",100)";
			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->update($strSQL); 
           			
			echo "1"; 
			exit();    	
    	}

         case "EditEmpName":   //修改客服
    	{
			$EID = $_POST["EID"];
			$empName = $_POST["empName"];
			$empPwd = $_POST["empPwd"];
			$imNumber = $_POST["imNumber"];
			$imType = $_POST["imType"];
			
			$empName=str_replace(' or ', '',$empName); //防止有人作弊
			$empName=str_replace(' || ', '',$empName); //防止有人作弊
			$empPwd=str_replace(' ', '',$empPwd);      //防止有人作弊
			
			$strSQL="select count(*) AS RowNum ";  
			$strSQL .="from empInfo ";  
			$strSQL .="where empName='".$empName."' AND shopRoomID='".$_SESSION["UID"]."'";

			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->query($strSQL); 
	      	$result=$db->fetch($DBR);
		    $rs_count=$result["RowNum"];
		    
		    if($rs_count>0)
		    {
				echo "2";   //用户或密码错误
				exit();		
			}
			

		    //新增客服资料
			$strSQL ="UPDATE empInfo ";
			$strSQL.="Set empName='".$empName."',";
			$strSQL.="    empPwd='".$empPwd."',";
			$strSQL.="    imNumber='".$imNumber."',";
			$strSQL.="    imType=".$imType." ";
			$strSQL.="WHERE id='".$EID."'";
			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->update($strSQL); 
           			
			echo "1"; 
			exit();    	
    	}

         case "empNameNum":   //新增时判断是否会超出允许人数
    	{
			$strSQL="select count(*) AS RowNum ";  
			$strSQL .="from empInfo ";  
			$strSQL .="where shopRoomID='".$_SESSION["UID"]."'";

			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->query($strSQL); 
	      	$result=$db->fetch($DBR);
		    $empNum=$result["RowNum"];

			$strSQL="select effectNum ";  
			$strSQL .="from userInfo ";  
			$strSQL .="where id='".$_SESSION["UID"]."'";

			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->query($strSQL); 
	      	$result=$db->fetch($DBR);
		    $effectNum=$result["effectNum"];
		    
		    if($empNum>=$effectNum)
		    {
				echo "2";   //用户或密码错误
				exit();		
			}
           			
			echo "1"; 
			exit();    	
    	}

        case "DeleteUser":   //删除会员
    	{
    		if($_SESSION["UID"]=="" || $_SESSION['flag']!='6275ffcfb9cd8f95984b93b0a7bfcefd')
			{
				$h_tourl="login.php";
				header("Location:".$h_tourl);
				exit;
			}
		  	$UID = $_POST["UID"];
		
		    //删除会员资料
			$strSQL = "DELETE FROM userInfo WHERE id='$UID'";
			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->update($strSQL); 
		
		    //删除聊天室资料
			$strSQL = "DELETE FROM roomBaseInfo WHERE shopRoomID='$UID'";
			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->update($strSQL); 

		    //删除客服资料
			$strSQL = "DELETE FROM empInfo WHERE shopRoomID='$UID'";
			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->update($strSQL); 

//		    echo $strSQL;
			echo "1"; 
			exit();

			break;  
    	}

		
         case "AddUserName":   //代理商新增会员注册
    	{
			
			$userName = strval($_POST["userName"]);
			$userPWD = strval($_POST["userPWD"]);
			$email = $_POST["email"];
			$telCode = $_POST["telCode"];
			$qqCode = $_POST["qqCode"];
			$userAddress = $_POST["userAddress"];
			$realName = $_POST["realName"];
			
			$pwdkey = '@#$%';
			$userPWD = md5($userPWD.$pwdkey);
			
			$strSQL="select count(*) AS RowNum ";  
			$strSQL .="from userInfo ";  
			$strSQL .="where userName='$userName' limit 0,1 ";

			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->query($strSQL); 
	      	$result=$db->fetch($DBR);
		    $rs_count=$result["RowNum"];
		    
		    if($rs_count>0)
		    {
				echo "2";   //用户或密码错误
				exit();		
			}
			

		    //新增用户资料
			$qry="INSERT INTO userInfo (pid,userName,userPWD,email,telCode,qqCode,realName,userAddress,loginTime,type) ";  
			$qry .= "VALUES ('".$_SESSION["UID"]."','$userName','$userPWD','$email','$telCode','$qqCode','$realName','$userAddress',now(),0)"; 			//默认1个客服数量
			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->update($qry); 

			$strSQL="select * ";  
			$strSQL .="from userInfo ";  
			$strSQL .="where userName='$userName' limit 0,1 ";

			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->query($strSQL); 
	      	$result=$db->fetch($DBR);
           			
			echo "1"; 
			exit();    	
    	}
    	
        case "EditUserName":   //代理商修改会员资料
    	{
		  	$EID = $_POST["EID"];
		  	$userPWD = $_POST["userPWD"];
		  	$email = $_POST["email"];
		  	$telCode = $_POST["telCode"];
		  	$qqCode = $_POST["qqCode"];
		  	//更改资料
		  	if(!empty($userPWD)){
		  		$pwdkey = '@#$%';
				$userPWD = md5($userPWD.$pwdkey);
		  		$strSQL = "update userInfo set userPWD='$userPWD',email='$email',telCode='$telCode',qqCode='$qqCode' where id='$EID' limit 1 ";
		  	}else{
		  		$strSQL = "update userInfo set email='$email',telCode='$telCode',qqCode='$qqCode' where id='$EID' limit 1 ";	
		  	}
			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->update($strSQL); 
		
//		    echo $strSQL;
			echo "1"; 
			exit();

			break;  
    	}


         


    	    	
    	case "AddGoods":   //增加产品
    	{
    		if($_SESSION["UID"]=="" || $_SESSION['flag']!='6275ffcfb9cd8f95984b93b0a7bfcefd')
			{
				$h_tourl="login.php";
				header("Location:".$h_tourl);
				exit;
			}
			$goodsid = $_POST["goodsid"];
			$goodsname = $_POST["goodsname"];
			$goodsname_e = $_POST["goodsname_e"];
			$colorid = $_POST["colorid"];
			$year = $_POST["year"];
			$season = $_POST["season"];
			$sort1id = $_POST["sort1id"];
			$sort2id = $_POST["sort2id"];
			$sort3id = $_POST["sort3id"];
			$sort4id = $_POST["sort4id"];
			$sort5id = $_POST["sort5id"];
			$sizeid = $_POST["sizeid"];
			$adviceprice = $_POST["adviceprice"];
			$isnewstyle = $_POST["isnewstyle"];
			$issale = $_POST["issale"];
			$remark = $_POST["remark"];
			$remark_e = $_POST["remark_e"];
			
			$goodsid=str_replace(' or ', '',$goodsid); //防止有人作弊
			$goodsid=str_replace(' || ', '',$goodsid); //防止有人作弊
			$goodsname=str_replace(' ', '',$goodsname);      //防止有人作弊

		    //增加产品
			$qry ="INSERT INTO goods (goodsid,goodsname,goodsname_e,colorid,year,season,sort1id,sort2id,sort3id,sort4id,sort5id,";  
			$qry.="                   sizeid,cost,price,adviceprice,specialprice,isnewstyle,issale,remark,remark_e,createdate,createuserid,changedate,changeuserid) ";  
			$qry.= "VALUES ('$goodsid','$goodsname','$goodsname_e','$colorid','$year','$season','$sort1id','$sort2id','$sort3id','$sort4id','$sort5id',";
			$qry.="         '$sizeid',0,0,".$adviceprice.",0,'$isnewstyle','$issale','$remark','$remark_e',now(),'".$_SESSION["UID"]."',now(),'".$_SESSION["UID"]."') "; 		
			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->update($qry); 

			echo "1"; 
			exit();    	
    	}


        case "EditGoods":   //修改产品
    	{
    		if($_SESSION["UID"]=="" || $_SESSION['flag']!='6275ffcfb9cd8f95984b93b0a7bfcefd')
			{
				$h_tourl="login.php";
				header("Location:".$h_tourl);
				exit;
			}
		  	$EID = $_POST["EID"];
			$goodsid = $_POST["goodsid"];
			$goodsname = $_POST["goodsname"];
			$goodsname_e = $_POST["goodsname_e"];
			$colorid = $_POST["colorid"];
			$year = $_POST["year"];
			$season = $_POST["season"];
			$sort1id = $_POST["sort1id"];
			$sort2id = $_POST["sort2id"];
			$sort3id = $_POST["sort3id"];
			$sort4id = $_POST["sort4id"];
			$sort5id = $_POST["sort5id"];
			$sizeid = $_POST["sizeid"];
			$adviceprice = $_POST["adviceprice"];
			$isnewstyle = $_POST["isnewstyle"];
			$issale = $_POST["issale"];
			$remark = $_POST["remark"];
			$remark_e = $_POST["remark_e"];
			
			$goodsid=str_replace(' or ', '',$goodsid); //防止有人作弊
			$goodsid=str_replace(' || ', '',$goodsid); //防止有人作弊
			$goodsname=str_replace(' ', '',$goodsname);      //防止有人作弊
					
		    //更改资料
			$strSQL ="UPDATE goods ";
			$strSQL.="SET goodsid='$goodsid',";
			$strSQL.="    goodsname='$goodsname',";
			$strSQL.="    goodsname_e='$goodsname_e',";
			$strSQL.="    colorid='$colorid',";
			$strSQL.="    year='$year',";
			$strSQL.="    season='$season',";
			$strSQL.="    sort1id='$sort1id',";
			$strSQL.="    sort2id='$sort2id',";
			$strSQL.="    sort3id='$sort3id',";
			$strSQL.="    sort4id='$sort4id',";
			$strSQL.="    sort5id='$sort5id',";
			$strSQL.="    sizeid='$sizeid',";
			$strSQL.="    cost=0,";
			$strSQL.="    price=0,";
			$strSQL.="    adviceprice=".$adviceprice.",";
			$strSQL.="    specialprice=0,";
			$strSQL.="    isnewstyle='$isnewstyle',";
			$strSQL.="    issale='$issale',";
			$strSQL.="    remark='$remark',";
			$strSQL.="    remark_e='$remark_e',";
			$strSQL.="    changedate=now(),";
			$strSQL.="    changeuserid='".$_SESSION["UID"]."' ";  
			$strSQL.= "WHERE id='".$EID."' limit 1 ";
			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->update($strSQL); 
		
//		    echo $strSQL;
			echo "1"; 
			exit();

			break;  
    	}
    	
        case "DeleteGoods":   //删除产品
    	{
    		if($_SESSION["UID"]=="" || $_SESSION['flag']!='6275ffcfb9cd8f95984b93b0a7bfcefd')
			{
				$h_tourl="login.php";
				header("Location:".$h_tourl);
				exit;
			}
		  	$UID = $_POST["UID"];
		
			$strSQL = "DELETE FROM goods WHERE id='$UID'";
			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->update($strSQL); 
		
			echo "1"; 
			exit();

			break;  
    	}

        case "DeleteColor":   //删除颜色
    	{
    		if($_SESSION["UID"]=="" || $_SESSION['flag']!='6275ffcfb9cd8f95984b93b0a7bfcefd')
			{
				$h_tourl="login.php";
				header("Location:".$h_tourl);
				exit;
			}
		  	$UID = $_POST["UID"];
		
			$strSQL = "DELETE FROM color WHERE id='$UID'";
			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->update($strSQL); 
		
			echo "1"; 
			exit();

			break;  
    	}
    	
    	
   		case "DeleteImages":   //删除首页图片
    	{
    		if($_SESSION["UID"]=="" || $_SESSION['flag']!='6275ffcfb9cd8f95984b93b0a7bfcefd')
			{
				$h_tourl="login.php";
				header("Location:".$h_tourl);
				exit;
			}
		  	$UID = $_POST["UID"];
		  	$strSQL = "select url FROM images WHERE id='$UID'";
			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->query($strSQL); 
	      	$result=$db->fetch($DBR);
	      	$pic = $result['url'];
		  	if(@unlink('pic/'.$result['url'])){
				$strSQL = "DELETE FROM images WHERE id='$UID'";
				$db = MySQL::getInstance('','r-w'); 
				$DBR=$db->update($strSQL); 
				echo 1; 
				exit();
		  	}else{
		  		echo 2; 
				exit();
		  	}
			break;  
    	}


    	case "AddColor":   //增加颜色
    	{
    		if($_SESSION["UID"]=="" || $_SESSION['flag']!='6275ffcfb9cd8f95984b93b0a7bfcefd')
			{
				$h_tourl="login.php";
				header("Location:".$h_tourl);
				exit;
			}
			$colorname = $_POST["colorname"];
			$colorname_e = $_POST["colorname_e"];
			$remark = $_POST["remark"];

		    //增加颜色
			$qry ="INSERT INTO color (colorname,colorname_e,remark,createdate,createuserid,changedate,changeuserid) ";  
			$qry.= "VALUES ('$colorname','$colorname_e','$remark',now(),'".$_SESSION["UID"]."',now(),'".$_SESSION["UID"]."') "; 		
			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->update($qry); 
          			
			echo "1"; 
			exit();    	
    	}

        case "EditColor":   //修改颜色
    	{
    		if($_SESSION["UID"]=="" || $_SESSION['flag']!='6275ffcfb9cd8f95984b93b0a7bfcefd')
			{
				$h_tourl="login.php";
				header("Location:".$h_tourl);
				exit;
			}
		  	$EID = $_POST["EID"];
			$colorname = $_POST["colorname"];
			$colorname_e = $_POST["colorname_e"];
			$remark = $_POST["remark"];
					
		    //修改颜色
			$strSQL ="UPDATE color ";
			$strSQL.="SET colorname='$colorname',";
			$strSQL.="    colorname_e='$colorname_e',";
			$strSQL.="    remark='$remark',";
			$strSQL.="    changedate=now(),";
			$strSQL.="    changeuserid='".$_SESSION["UID"]."' ";  
			$strSQL.= "WHERE id='".$EID."' limit 1 ";
			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->update($strSQL); 
		
//		    echo $strSQL;
			echo "1"; 
			exit();

			break;  
    	}
    	
        case "DeleteSeason":   //删除季别
    	{
    		if($_SESSION["UID"]=="" || $_SESSION['flag']!='6275ffcfb9cd8f95984b93b0a7bfcefd')
			{
				$h_tourl="login.php";
				header("Location:".$h_tourl);
				exit;
			}
    		if($_SESSION["UID"]=="" || $_SESSION['flag']!='6275ffcfb9cd8f95984b93b0a7bfcefd')
			{
				$h_tourl="login.php";
				header("Location:".$h_tourl);
				exit;
			}
		  	$UID = $_POST["UID"];
		
			$strSQL = "DELETE FROM season WHERE id='$UID'";
			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->update($strSQL); 
		
			echo "1"; 
			exit();

			break;  
    	}


    	case "AddSeason":   //增加季别
    	{
    		if($_SESSION["UID"]=="" || $_SESSION['flag']!='6275ffcfb9cd8f95984b93b0a7bfcefd')
			{
				$h_tourl="login.php";
				header("Location:".$h_tourl);
				exit;
			}
			$seasonname = $_POST["seasonname"];
			$seasonname_e = $_POST["seasonname_e"];
			$remark = $_POST["remark"];

		    //增加季别
			$qry ="INSERT INTO season (season,season_e,remark,createdate,createuserid,changedate,changeuserid) ";  
			$qry.= "VALUES ('$seasonname','$seasonname_e','$remark',now(),'".$_SESSION["UID"]."',now(),'".$_SESSION["UID"]."') "; 		
			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->update($qry); 
          			
			echo "1"; 
			exit();    	
    	}

        case "EditSeason":   //修改季别
    	{
    		if($_SESSION["UID"]=="" || $_SESSION['flag']!='6275ffcfb9cd8f95984b93b0a7bfcefd')
			{
				$h_tourl="login.php";
				header("Location:".$h_tourl);
				exit;
			}
		  	$EID = $_POST["EID"];
			$seasonname = $_POST["seasonname"];
			$seasonname_e = $_POST["seasonname_e"];
			$remark = $_POST["remark"];
					
		    //修改季别
			$strSQL ="UPDATE season ";
			$strSQL.="SET season='$seasonname',";
			$strSQL.="    season_e='$seasonname_e',";
			$strSQL.="    remark='$remark',";
			$strSQL.="    changedate=now(),";
			$strSQL.="    changeuserid='".$_SESSION["UID"]."' ";  
			$strSQL.= "WHERE id='".$EID."' limit 1 ";
			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->update($strSQL); 
		
//		    echo $strSQL;
			echo "1"; 
			exit();

			break;  
    	}    	
    	


        case "DeleteSort":   //删除类别
    	{
    		if($_SESSION["UID"]=="" || $_SESSION['flag']!='6275ffcfb9cd8f95984b93b0a7bfcefd')
			{
				$h_tourl="login.php";
				header("Location:".$h_tourl);
				exit;
			}
		  	$UID = $_POST["UID"];
		  	$SortNo = $_POST["SortNo"];
		
			$strSQL = "DELETE FROM sort".$SortNo." WHERE id='".$UID."'";
			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->update($strSQL); 
		
			echo "1"; 
			exit();

			break;  
    	}


    	case "AddSort":   //增加类别
    	{
    		if($_SESSION["UID"]=="" || $_SESSION['flag']!='6275ffcfb9cd8f95984b93b0a7bfcefd')
			{
				$h_tourl="login.php";
				header("Location:".$h_tourl);
				exit;
			}
			$sortname = $_POST["sortname"];
			$sortname_e = $_POST["sortname_e"];
			$remark = $_POST["remark"];
			$SortNo = $_POST["SortNo"];

		    //增加类别
			$qry ="INSERT INTO sort".$SortNo." (sort".$SortNo."name,sort".$SortNo."name_e,remark,createdate,createuserid,changedate,changeuserid) ";  
			$qry.= "VALUES ('$sortname','$sortname_e','$remark',now(),'".$_SESSION["UID"]."',now(),'".$_SESSION["UID"]."') "; 		
			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->update($qry); 
          			
			echo "1"; 
			exit();    	
    	}

        case "EditSort":   //修改类别
    	{
    		if($_SESSION["UID"]=="" || $_SESSION['flag']!='6275ffcfb9cd8f95984b93b0a7bfcefd')
			{
				$h_tourl="login.php";
				header("Location:".$h_tourl);
				exit;
			}
		  	$EID = $_POST["EID"];
			$sortname = $_POST["sortname"];
			$sortname_e = $_POST["sortname_e"];
			$remark = $_POST["remark"];
			$SortNo = $_POST["SortNo"];
					
		    //修改季别
			$strSQL ="UPDATE sort".$SortNo." ";
			$strSQL.="SET sort".$SortNo."name='$sortname',";
			$strSQL.="    sort".$SortNo."name_e='$sortname_e',";
			$strSQL.="    remark='$remark',";
			$strSQL.="    changedate=now(),";
			$strSQL.="    changeuserid='".$_SESSION["UID"]."' ";  
			$strSQL.= "WHERE id='".$EID."' limit 1 ";
			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->update($strSQL); 
		
//		    echo $strSQL;
			echo "1"; 
			exit();

			break;  
    	}    	

        case "DeleteSize":   //删除配码
    	{
    		if($_SESSION["UID"]=="" || $_SESSION['flag']!='6275ffcfb9cd8f95984b93b0a7bfcefd')
			{
				$h_tourl="login.php";
				header("Location:".$h_tourl);
				exit;
			}
		  	$UID = $_POST["UID"];
		
			$strSQL = "DELETE FROM size WHERE id='$UID'";
			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->update($strSQL); 
		
			echo "1"; 
			exit();

			break;  
    	}


    	case "AddSize":   //增加配码
    	{
    		if($_SESSION["UID"]=="" || $_SESSION['flag']!='6275ffcfb9cd8f95984b93b0a7bfcefd')
			{
				$h_tourl="login.php";
				header("Location:".$h_tourl);
				exit;
			}
			$remark = $_POST["remark"];
			$size01 = $_POST["size01"];
			$size02 = $_POST["size02"];
			$size03 = $_POST["size03"];
			$size04 = $_POST["size04"];
			$size05 = $_POST["size05"];
			$size06 = $_POST["size06"];
			$size07 = $_POST["size07"];
			$size08 = $_POST["size08"];
			$size09 = $_POST["size09"];
			$size10 = $_POST["size10"];

		    //增加配码
			$qry ="INSERT INTO size (size01,size02,size03,size04,size05,size06,size07,size08,size09,size10,remark,createdate,createuserid,changedate,changeuserid) ";  
			$qry.= "VALUES ('$size01','$size02','$size03','$size04','$size05','$size06','$size07','$size08','$size09','$size10','$remark',now(),'".$_SESSION["UID"]."',now(),'".$_SESSION["UID"]."') "; 		
			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->update($qry); 
          			
			echo "1"; 
			exit();    	
    	}

        case "EditSize":   //修改配码
    	{
		  	$EID = $_POST["EID"];
			$remark = $_POST["remark"];
			$size01 = $_POST["size01"];
			$size02 = $_POST["size02"];
			$size03 = $_POST["size03"];
			$size04 = $_POST["size04"];
			$size05 = $_POST["size05"];
			$size06 = $_POST["size06"];
			$size07 = $_POST["size07"];
			$size08 = $_POST["size08"];
			$size09 = $_POST["size09"];
			$size10 = $_POST["size10"];
					
		    //修改颜色
			$strSQL ="UPDATE size ";
			$strSQL.="SET size01='$size01',";
			$strSQL.="    size02='$size02',";
			$strSQL.="    size03='$size03',";
			$strSQL.="    size04='$size04',";
			$strSQL.="    size05='$size05',";
			$strSQL.="    size06='$size06',";
			$strSQL.="    size07='$size07',";
			$strSQL.="    size08='$size08',";
			$strSQL.="    size09='$size09',";
			$strSQL.="    size10='$size10',";
			$strSQL.="    remark='$remark',";
			$strSQL.="    changedate=now(),";
			$strSQL.="    changeuserid='".$_SESSION["UID"]."' ";  
			$strSQL.= "WHERE id='".$EID."' limit 1 ";
			$db = MySQL::getInstance('','r-w'); 
			$DBR=$db->update($strSQL); 
		
//		    echo $strSQL;
			echo "1"; 
			exit();

			break;  
    	}
    	













    	
    	default:
		{
			echo "0";
			break;
		}
    
	}
?>
    	
